describe ("ZDom", function(){

    describe ("Basic, common facade methods", function(){
        var parentElem,
            newDiv;

        beforeEach (function(){
            parentElem = document.getElementsByTagName("body")[0];
            newDiv = document.createElement('div');
            newDiv.setAttribute("class", "myClass");
            newDiv.setAttribute("id", "myId");
            parentElem.appendChild(newDiv);
        });

        afterEach (function(){
            parentElem.removeChild(newDiv);
        });

        it ("finding", function(){

            expect(zdom("#myId").el).toEqual(newDiv);
            expect(zdom(".myClass").el).toEqual(newDiv);

        });

        it ("should set element's attributes", function(){

            zdom("#myId").attr("class", "1234");
            expect(zdom("#myId").el.getAttribute("class")).toEqual("1234");

        });

        it ("should remove element's attributes", function(){

            zdom("#myId").removeAttr("class", "myClass");
            expect(zdom("#myId").el.className).toEqual("");

        });

    });

    describe ("Hiding of dom elements" , function(){
        var parentElem,
            newDiv;

        beforeEach (function(){
            parentElem = document.getElementsByTagName("body")[0];
            newDiv = document.createElement('div');
            newDiv.setAttribute("class", "myClass");
            newDiv.setAttribute("id", "myId");
            parentElem.appendChild(newDiv);
        });

        afterEach (function(){
            parentElem.removeChild(newDiv);
        });

        it ("can hide element by given selector ", function(){

            zdom("#myId").hide();
            expect(zdom("#myId").el.getAttribute("display")).toEqual("none");

        });

        it("should change opacity by time", function() {
            var sinonTimer = sinon.useFakeTimers();
            zdom("#myId").hide(4000);

            sinonTimer.tick(2000);
            var status = zdom("#myId").el.getAttributeNode("opacity").value;
            expect(status).toBe("0.5");
            sinonTimer.tick(1000);
            status = zdom("#myId").el.getAttributeNode("opacity").value;
            expect(status).toBe("0.25");
        });

    });

    describe ("showing" , function(){
        var parentElem,
            newDiv;

        beforeEach (function(){
            parentElem = document.getElementsByTagName("body")[0];
            newDiv = document.createElement('div');
            newDiv.setAttribute("class", "myClass");
            newDiv.setAttribute("id", "myId");
            parentElem.appendChild(newDiv);
        });

        afterEach (function(){
            parentElem.removeChild(newDiv);
        });

        it ("can show element by given selector", function(){

            zdom("#myId").show();
            expect(zdom("#myId").el.getAttribute("display")).toEqual("block");

        });

        it("should change opacity by time", function() {
            var sinonTimer = sinon.useFakeTimers();
            zdom("#myId").show(4000);

            sinonTimer.tick(2000);
            var status = zdom("#myId").el.getAttributeNode("opacity").value;
            expect(status).toBe("0.5");
            sinonTimer.tick(1000);
            status = zdom("#myId").el.getAttributeNode("opacity").value;
            expect(status).toBe("0.75");
        });

    });

    describe ("slideDown" , function(){
        var parentElem,
            newDiv;

        beforeEach (function(){
            parentElem = document.getElementsByTagName("body")[0];
            newDiv = document.createElement('div');
            newDiv.setAttribute("id", "myId");
            newDiv.setAttribute("style", "height:200px");
            parentElem.appendChild(newDiv);
        });

        afterEach (function(){
            parentElem.removeChild(newDiv);
        });

        it("should change el height by time", function() {
            var sinonTimer = sinon.useFakeTimers();
            zdom("#myId").slideDown(4000);

            sinonTimer.tick(2000);
            var status = zdom("#myId").el.getAttributeNode("style").value;
            expect(status).toBe("height :100px");
        });

    });

})
